package net.diaowen.dwsurvey.common;

public class AnswerResult {

    // 是否成功
    private boolean success;
    // 更新令牌,防止重复提交
    private String token;
    // 错误信息
    private String errorMessage;
    // 重定向URL
    private String redirectUrl;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getRedirectUrl() {
        return redirectUrl;
    }

    public void setRedirectUrl(String redirectUrl) {
        this.redirectUrl = redirectUrl;
    }

    public void setErrorCode(int code) {
        if (code == 1) {
            this.errorMessage = "目前该问卷已暂停收集，请稍后再试!";
        } else if (code == 2) {
            this.errorMessage = "目前该问卷无法访问，请稍后再试!";
        } else if (code == 3) {
            this.errorMessage = "已经答过本问卷，请不要重复作答!";
        } else if (code == 4) {
            this.errorMessage = "验证码不正确，操作未成功!";
        } else if (code == 5) {
            this.errorMessage = "发生未知异常，操作未成功!";
        } else if (code == 7) {
            this.errorMessage = "答卷已经达到收集上限，感谢您的支持!（数据不被保存）";
        } else if (code == 8) {
            this.errorMessage = "问卷未到开始时间，感谢您的支持!（数据不被保存）";
        } else if (code == 9) {
            this.errorMessage = "问卷已经到了截止时间，感谢您的支持!（数据不被保存）";
        } else if (code == 10) {
            this.errorMessage = "该问卷已删除，无法作答!";
        } else if (code == 21) {
            this.errorMessage = "不在本次调研范围内，无法作答!";
        } else if (code == 23) {
            this.errorMessage = "超过单个IP答卷次数限制!";
        } else if (code == 106) {
            this.errorMessage = "口令超过使用次数!";
        } else if (code == 302) {
            this.errorMessage = "口令码错误!";
        } else if (code == 303) {
            this.errorMessage = "需要口令才可以回答问卷!";
        } else if (code == 202) {
            this.errorMessage = "超过有效答卷次数!";
        }
    }
}